﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.flashsale {
    import Display.DialogUI.*;
    import Modules.stats.experiments.*;
    import Modules.flashsale.ui.*;

    public class FlashSaleManager {

        public static const DEFAULT_COOLDOWN:int = 300;
        public static const DEFAULT_MINLEVEL:int = 5;
        public static const ACTIVATION_FLAG:String = "flashSale_lastSeen";
        public static const VAR_NOTIF_COOLDOWN:String = "flashSaleNotifCooldown";
        public static const VAR_MINLEVEL:String = "flashSaleMinLevel";

        protected var m_variant:int = 0;
        protected var m_flashSales:Array;
        protected var m_coolDownPeriod:int = -1;
        protected var m_minLevel:int = 0;

        public function FlashSaleManager(){
            this.m_flashSales = new Array();
            super();
            this.m_variant = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_FLASHSALE);
            this.m_flashSales = Global.gameSettings.getFlashSaleData();
            this.m_coolDownPeriod = Global.gameSettings.getInt(VAR_NOTIF_COOLDOWN, DEFAULT_COOLDOWN);
            this.m_minLevel = Global.gameSettings.getInt(VAR_MINLEVEL, DEFAULT_MINLEVEL);
        }
        public function get saleVariant():int{
            return (this.m_variant);
        }
        public function get isFlashSaleAvailable():Boolean{
            return (((((!(Global.player.isNewPlayer)) && ((Global.player.level >= this.m_minLevel)))) && ((this.m_flashSales.length > 0))));
        }
        public function get isCooldownActive():Boolean{
            var _local1:int = (GlobalEngine.getCurrentTime() / 1000);
            return (((_local1 - this.m_coolDownPeriod) <= Global.player.getLastActivationTime(ACTIVATION_FLAG)));
        }
        public function getPaymentsPackageSet():int{
            return (this.m_flashSales[0].packageSetId);
        }
        public function getFeaturedPackages():Array{
            return (this.m_flashSales[0].featuredSales);
        }
        public function getSaleDiscount():int{
            return (this.m_flashSales[0].featuredSales[0].discount);
        }
        public function getRedirectUrl(_arg1:int=0):String{
            var _local2 = "money.php?ref=flashsale";
            if (_arg1 != 0){
                return (((_local2 + "&selid=") + _arg1.toString()));
            };
            return (_local2);
        }
        public function getStartupDialog():GenericDialog{
            return (new FlashSaleDialog("", "FlashSale", GenericDialogView.TYPE_MODAL, this.onCloseStartup, "", "", true, 0, "", this.onCloseStartup, ""));
        }
        public function getIdleDialog():GenericDialog{
            return (new FlashSaleMiniDialog("", "FlashSale", GenericDialogView.TYPE_MODAL, null, "", "", true, 0, "", null, ""));
        }
        private function onCloseStartup(_arg1=null):void{
            Global.player.setLastActivationTime(ACTIVATION_FLAG, GlobalEngine.getCurrentTime());
        }

    }
}//package Modules.flashsale 
